1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { fail, redirect } from '@sveltejs/kit';
import { btc as asset, auth, post } from '$lib/utils';
export async function load({ params }) {
return post('/parse', params);
}
export const actions = {
setAmount: async ({ cookies, request }) => {
return Object.fromEntries(await request.formData());
},
send: async ({ cookies, request }) => {
try {
let body = Object.fromEntries(await request.formData());
let { amount, confirmed } = body;
console.log('AMOUNT', amount);
if (!confirmed) {
return fail(400, { amount, confirm: true });
}
await post('/payments', body, auth(cookies));
} catch (e) {
if (e.message.includes('unusable'))
e.message = 'Failed to route payment, try sending a lower amount';
return fail(400, { message: e.message });
}
throw redirect(307, '/sent');
}
};
|